<!--
Copyright 2015 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
file except in compliance with the License. You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied. See the License for the specific language governing
permissions and limitations under the License.
-->
<!DOCTYPE html>

<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
  <script src="../bower_components/webcomponentsjs/webcomponents.js"></script>
  <script src="../bower_components/web-component-tester/browser.js"></script>
  <link rel="import" href="../google-map-storyboard.html">
</head>
<body>

    <google-map-storyboard id="withoutIds" fit current="NonExistant"
        apiKey="AIzaSyCuocpy_Ekp1WM0x5t7hdBdE0nr_dmWZtE">
      <google-map-scene address="Mountain View" zoom="7">ABC</google-map-scene>
      <google-map-scene address="Sydney, Australia" zoom="5"></google-map-scene>
      <google-map-scene address="Zurich, Switzerland"></google-map-scene>
    </google-map-storyboard>

<script>

suite('google-map-storyboard', function() {
  suiteSetup(function(done) {
    withoutIds.addEventListener('google-map-storyboard-ready', function() {
      done();
    });
  });

  test('initialScene', function() {
    assert.equal(withoutIds.current,'');
    assert.equal(withoutIds.currentScene, withoutIds.validScenes.getAt(0));
    assert.equal(withoutIds.map.getCenter(),
        withoutIds.currentScene.location);
  })

  test('mapReadyEvent', function() {
    var map = withoutIds.map;
    assert.isTrue(map instanceof google.maps.Map);
    assert.equal(map.getZoom(), 7);
    assert.equal(map.getCenter(), withoutIds.validScenes.getAt(0).location);
    // Ensure that there are 3 buttons at the bottom: prev, pause, next.
    var mapControls = map.controls[google.maps.ControlPosition.BOTTOM_CENTER];
    assert.equal(mapControls.length, 1);

    var controlsDiv = withoutIds.$.controls;
    assert.equal(controlsDiv.children.length, 3);

    var expectedControlsIds = ['prev', 'pauseAndPlay', 'next'];
    for (var i = 0; i < expectedControlsIds.length; ++i) {
      assert.equal(controlsDiv.children[i].id, expectedControlsIds[i],
          'The order of the controls at the bottom of the map.');
    }
  });

});

</script>
</body>
</html>
